import 'package:flutter/material.dart';

import 'package:rainflutter/config/routes.dart';
import 'package:rainflutter/main.dart';
import 'package:rainflutter/pages/controller/page/provide/inherited_change_test.dart';

class InheritedTest extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // Image nose =
    //     context.dependOnInheritedWidgetOfExactType<InheritedNose>().asset;

    // nose = Image.asset('assets/images/calendar_summer.png');
    LoginState loginState = InheritedLoginWidget.of(context).loginState;
    return Scaffold(
      appBar: AppBar(title: Text('状态管理-Inherited')),
      body: Column(children: [
        TextButton(
          onPressed: () {},
          child: Text('data'),
          style: ButtonStyle(
            textStyle: MaterialStateProperty.all(
                TextStyle(fontSize: 14, fontWeight: FontWeight.normal)),
            foregroundColor: MaterialStateProperty.all(Colors.pink),
            backgroundColor: MaterialStateProperty.all(Colors.pink),
            minimumSize: MaterialStateProperty.all(Size(50, 20)),
            // tapTargetSize:
          ),
        ),
        TextButton(
          style: TextButton.styleFrom(
            minimumSize: Size(MediaQuery.of(context).size.width - 32, 44),
            tapTargetSize: MaterialTapTargetSize.shrinkWrap,
            primary: Colors.white,
            onSurface: Colors.orange,
            shadowColor: Colors.red,
            backgroundColor: Colors.green,
          ),
          child: Text(
            '下一步',
            style: TextStyle(
                color: Colors.amber,
                fontSize: 18,
                fontWeight: FontWeight.normal),
          ),
          onPressed: () {
            //去偏好设置
          },
        ),
        Image.asset(InheritedImageWidget?.of(context)?.imageUrl ??
            'assets/images/calendar_summer.png'),
        TextButton(
          child: Text(loginState.isLogin ? '登录' : '未登录'),
          onPressed: () {
            loginState.isLogin = !loginState.isLogin;
            print('当前变更成：${loginState.isLogin ? '登录' : '未登录'}状态');
          },
        ),
        OutlinedButton(
          onPressed: () {
            Navigator.of(context).pushNamed(Routes.InheritedChangeTest);
          },
          child: Text('下一个'),
        )
      ]),
    );
  }
}
